﻿/* Copyright © Hauer Engineering 2012 */

(function ($)
{
    // create default namespace
    if (!$.fn.heng)
    {
        $.fn.heng = function () { };
        $.fn.heng.prototype = {};
    }

    $.setupNamespace = function (ns, startingNs)
    {
        if (!startingNs)
            startingNs = $;

        var parts = ns.split('.');
        if (parts && parts.length > 0)
        {
            var firstPart = parts[0];
            if (!startingNs[firstPart])
                startingNs[firstPart] = {};

            var curNs = startingNs[firstPart];
            for (var index = 1; index < parts.length; index++)
            {
                var part = parts[index];
                if (!curNs[part])
                    curNs[part] = {};
                curNs = curNs[part];
            }
        }
    }
})(jQuery);